#include "Global.h"

void Global::initializeGame()
{
    // initialize allegro
    allegro_init();
    set_color_depth(32);
    install_keyboard();
    set_gfx_mode(GFX_AUTODETECT_WINDOWED, SCREEN_W_, SCREEN_H_, 0, 0);
    buffer = create_bitmap(SCREEN_W_, SCREEN_H_);
    p = new Player();
    p->Initialize();
}
void Global::updateGame()
{
    p->update();
    if(key[KEY_Q])
        running = false;
}

void Global::drawGame()
{
    // clear
    rectfill(buffer, 0, 0, SCREEN_W_, SCREEN_H_, makecol(0, 0, 0));
    //************************************************

    if(!p->flipped)
        draw_sprite(buffer, p->currentAnimation->getCurrentFrame(), p->X, p->Y);
    else
        draw_sprite_h_flip(buffer, p->currentAnimation->getCurrentFrame(), p->X, p->Y);


    //************************************************
    blit(buffer, screen, 0, 0, 0, 0, SCREEN_W_, SCREEN_H_);
}
Global* Global::instance;
